package com.mall.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.google.common.collect.Maps;
import com.mall.common.ServerResponse;
import com.mall.dao.MmallOrderMapper;
import com.mall.dao.MmallProductMapper;
import com.mall.dao.MmallUserMapper;
import com.mall.pojo.MmallOrderExample;
import com.mall.pojo.MmallProductExample;
import com.mall.pojo.MmallUserExample;
import com.mall.service.ICountService;

@Service
public class CountServiceImpl implements ICountService {

	@Autowired
	private MmallUserMapper userMapper;
	
	@Autowired
	private MmallProductMapper productMapper;
	
	@Autowired
	private MmallOrderMapper orderMapper;
	
	
	@Override
	public ServerResponse count() {
		
		Map<String,Integer> map = Maps.newHashMap();
		
		MmallUserExample example = new MmallUserExample();
		int userNumber = userMapper.countByExample(example );
		
		
		MmallProductExample example2 = new MmallProductExample();
		int productNumber = productMapper.countByExample(example2 );
		
		
		MmallOrderExample example3 = new MmallOrderExample();
		int orderNumber = orderMapper.countByExample(example3 );
		
		map.put("userCount", userNumber);
		map.put("productCount", productNumber);
		map.put("orderCount", orderNumber);
		
		return ServerResponse.createBySuccess(map);
		
	}

}
